<?php include HEADER; ?>

<link href="<?php echo __URL_BASE ?>css/jquery-ui.css" rel="stylesheet" type="text/css">
<script src="<?php echo __URL_BASE ?>js/jquery-ui.js" type="text/javascript"></script>

<style>
.slg{
	width: 50px !important;
	padding: 2px !important;
	position: relative;
	top: 1px;
	left: 5px;
}
input[type=radio]{
	position: relative;
	top: 3px;
}
</style>
<?php
	$hoten = (isset($user)) ? $user->HoTen : '';
	$tendangnhap = (isset($user)) ? $user->TenDangNhap : ''; //echo $tendangnhap; die;
	$email = (isset($user)) ? $user->Email : '';
	$diachi = (isset($user)) ? $user->DiaChi : '';
	$dienthoai = (isset($user)) ? $user->DienThoai : '';
	$quyen = (isset($user)) ? $user->Quyen : '';
	$trangthai = (isset($user)) ? $user->TrangThai : '';
?>

<div >
<form method="post" action="<?php echo __URL_BASE.'index.php?rt=admin_user/change_pass_save' ?>" >

    <table class="TableUpdate" border="1">
    
        <tr>
            <td class="Control" colspan="2">
              <ul>
                <li>
                   <button type="submit" class="uupdate" style="border:none" >Ghi lại</button>
                </li>
                <li>
                  <label class="uback"  >Trở về</label>
                </li>
              </ul></td>
          </tr>
		  <tr >
            <th>Mật khẩu :</th>
            <td><input type="password"  class="text" name="tpass" required  value="<?php echo $tendangnhap ?>" <?php if(isset($_REQUEST['user_id'])) echo "readonly"; ?> /></td>
          </tr>
          <tr>
            <th>Mật khẩu mới :</th>
            <td><input type="password"  class="text"  name="tpassnew" required value="<?php echo $hoten ?>" /></td>
          </tr>
		  <tr>
            <th>Nhập lại mật khẩu mới :</th>
            <td><input type="password"  class="text" name="trepassnew"   required value="<?php echo $email ?>" /></td>
          </tr>
		   
		  
          <tr>
            <td class="Control" colspan="2">
              <ul>
                <li>
                  <button type="submit" class="uupdate" style="border:none" >Ghi lại</button>
                </li>
                <li>
                  <label class="uback"  >Trở về</label>
                </li>
              </ul></td>
          </tr>
    </table>
</form>

 </div>
 <script>
	$(document).ready(function(){
		$('.uupdate').click(function(){
			passnew = $('input[name=tpassnew]').val(); 
			if(!validatePass(passnew)){
				alert('Mật khẩu phải tuân thủ quy tắc sau. \n- Ít nhất 6 ký tự. \n- Có ít nhất 1 ký tự viết hoa.\n- Có ít nhất 1 ký tự viết thường.\n- Có ít nhất 1 ký tự là số.\n- Có ít nhất 1 ký tự đặc biệt.');
				$('#passwd').select();
				return false;
			}
			//check khớp mật khẩu
			
			repassnew = $('input[name=trepassnew]').val();
			//alert(passnew+'   ' + repassnew);
			if(passnew != repassnew){
				alert('Mật khẩu mới không khớp');
				return false;
			}
		});
		
		function validatePass($pass) { //it nhat 6 ky tu, co it nhat 1 ky tu viet hoa, viet thuong, 1 ky tu la so, 1 ky tu dac biet
	  var emailReg = /(?=^.{6,}$)(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[^A-Za-z0-9]).*/;
	  if( !emailReg.test( $pass ) ) {
		return false;
	  } else {
		return true;
	  }
	}
	});
</script>
<?php if(isset($message_user))  echo "<script>alert('".$message_user."');</script>";  ?>
<?php if(isset($message_email))  echo "<script>alert('".$message_email."');</script>";  ?>
<?php include FOOTER; ?>

<?php if(isset($msg)){echo '<script>alert("'.$msg.'");</script>';} ?>  
<?php if(isset($wrong_pass)){echo '<script>alert("'.$wrong_pass.'");</script>';} ?>  
